home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / mail / metamail / drafts / RFC-RICHTEXT.txt < prev    next >
Encoding:
Text File  |  1993-07-12  |  38.3 KB  |  970 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.             Network Working Group               N. Borenstein, Bellcore
  8.             Request for Comments: XXXX                   April 26, 1993
  9.  
  10.  
  11.  
  12.                         The text/enriched MIME Content-type
  13.  
  14.  
  15.             Status of this Memo
  16.  
  17.  
  18.             This  RFC  specifies  an  informational  protocol  for   the
  19.             Internet  community, and requests discussion and suggestions
  20.             for improvements.  Distribution of this memo is unlimited.
  21.  
  22.             Abstract
  23.  
  24.  
  25.             MIME [RFC-1341,  RFC-MIME]  defines  a  format  and  general
  26.             framework  for  the representation of a wide variety of data
  27.             types  in  Internet  mail.   This   document   defines   one
  28.             particular  type  of  MIME  data,  the text/enriched type, a
  29.             refinement of the "text/richtext" type defined in RFC  1341.
  30.             The  text/enriched  MIME  type is intended to facilitate the
  31.             wider interoperation of simple enriched text across  a  wide
  32.             variety of hardware and software platforms.
  33.  
  34.             The Text/enriched MIME type
  35.  
  36.  
  37.             In order to promote the  wider  interoperability  of  simple
  38.             formatted  text,  this  document defines an extremely simple
  39.             subtype of the MIME content-type "text", the "text/enriched"
  40.             subtype.   This  subtype  was designed to meet the following
  41.             criteria:
  42.  
  43.                  1.  The syntax must be extremely simple to  parse,
  44.                  so  that  even  teletype-oriented mail systems can
  45.                  easily strip away the formatting  information  and
  46.                  leave only the readable text.
  47.  
  48.                  2.  The syntax must be extensible to allow for new
  49.                  formatting  commands that are deemed essential for
  50.                  some application.
  51.  
  52.  
  53.  
  54.  
  55.  
  56.             Borenstein - text/eExpires September 1, 1993          Page 1
  57.  
  58.  
  59.  
  60.  
  61.             Borenstein     A text/enriched type for MIME  April 1993 [2]
  62.  
  63.  
  64.                  3.  If the character set in use is ASCII or an  8-
  65.                  bit  ASCII superset, then the raw form of the data
  66.                  must   be   readable   enough   to   be    largely
  67.                  unobjectionable  in the event that it is displayed
  68.                  on the screen of the user of a non-MIME-conformant
  69.                  mail reader.
  70.  
  71.                  4.  The capabilities must be extremely limited, to
  72.                  ensure  that  it  can  represent  no  more than is
  73.                  likely to be representable by the  user's  primary
  74.                  word  processor.   While  this  limits what can be
  75.                  sent, it increases the  likelihood  that  what  is
  76.                  sent can be properly displayed.
  77.  
  78.             This   document   defines   a   new    MIME    content-type,
  79.             "text/enriched".   The  content-type  line for this type may
  80.             have one optional parameter, the "charset"  parameter,  with
  81.             the   same   values  permitted  for  the  "text/plain"  MIME
  82.             content-type.
  83.  
  84.             The syntax of "text/enriched" is very simple.  It represents
  85.             text  in  a  single  character  set  -- US-ASCII by default,
  86.             although a different character set can be specified  by  the
  87.             use   of   the   "charset"  parameter.   (The  semantics  of
  88.             text/enriched in  non-ASCII  character  sets  are  discussed
  89.             later   in   this   document.)    All  characters  represent
  90.             themselves, with the exception of the "<"  character  (ASCII
  91.             60),  which  is  used  to mark the beginning of a formatting
  92.             command.   Formatting  instructions  consist  of  formatting
  93.             commands   surrounded  by angle brackets ("<>", ASCII 60 and
  94.             62).  Each  formatting  command  may  be  no  more  than  60
  95.             characters  in  length,  all  in US-ASCII, restricted to the
  96.             alphanumeric  and  hyphen   ("-")   characters.   Formatting
  97.             commands  may  be  preceded  by  a  solidus ("/", ASCII 47),
  98.             making them negations, and such negations must always  exist
  99.             to  balance  the  initial  opening  commands.   Thus, if the
  100.             formatting command "<bold>" appears  at  some  point,  there
  101.             must  later  be  a  "</bold>" to balance it.  (NOTE:  The 60
  102.             character limit on formatting commands does NOT include  the
  103.             "<",  ">",  or "/" characters that might be attached to such
  104.             commands.)
  105.  
  106.             Formatting commands are always case-insensitive.   That  is,
  107.             "bold"  and  "BoLd" are equivalent in effect, if not in good
  108.             taste.
  109.  
  110.  
  111.  
  112.  
  113.             Borenstein - text/eExpires September 1, 1993          Page 2
  114.  
  115.  
  116.  
  117.  
  118.             Borenstein     A text/enriched type for MIME  April 1993 [3]
  119.  
  120.  
  121.             Beyond tokens delimited by "<" and ">", there are two  other
  122.             special  processing  rules.  First, a literal less-than sign
  123.             ("<")  can  be  represented  by  a  sequence  of  two   such
  124.             characters,  "<<".    Second,  line  breaks  (CRLF  pairs in
  125.             standard network representation) are handled specially.   In
  126.             particular, isolated CRLF pairs are translated into a single
  127.             SPACE character.  Sequences of  N  consecutive  CRLF  pairs,
  128.             however,  are  translated into N-1 actual line breaks.  This
  129.             permits long lines of data to be represented in  a  natural-
  130.             looking  manner  despite  the  frequency of line-wrapping in
  131.             Internet  mailers.   When  preparing  the  data   for   mail
  132.             transport,  isolated line breaks should be inserted wherever
  133.             necessary to keep each  line  shorter  than  80  characters.
  134.             When  preparing  such  data  for  presentation  to the user,
  135.             isolated line breaks should be replaced by  a  single  SPACE
  136.             character,  and N consecutive CRLF pairs should be presented
  137.             to the user as N-1 line breaks.
  138.  
  139.             Thus text/enriched data that looks like this:
  140.                  This is
  141.                  a single
  142.                  line
  143.  
  144.                  This is the
  145.                  next line.
  146.  
  147.  
  148.                  This is the
  149.                  next paragraph.
  150.  
  151.             should  be  displayed  by  a  text/enriched  interpreter  as
  152.             follows:
  153.  
  154.                  This is a single line
  155.                  This is the next line.
  156.  
  157.                  This is the next paragraph.
  158.  
  159.             The  formatting  commands,  not  all  of   which   will   be
  160.             implemented  by  all  implementations,  are described in the
  161.             following sections.
  162.  
  163.             Formatting Commands
  164.  
  165.  
  166.             The  text/enriched  formatting  commands  all   begin   with
  167.  
  168.  
  169.  
  170.             Borenstein - text/eExpires September 1, 1993          Page 3
  171.  
  172.  
  173.  
  174.  
  175.             Borenstein     A text/enriched type for MIME  April 1993 [4]
  176.  
  177.  
  178.             <commandname>  and  end  with  </commandname>, affecting the
  179.             formatting of  the  text  between  those  two  tokens.   The
  180.             commands are described here, grouped according to type.
  181.  
  182.             Font-Alteration Commands
  183.  
  184.             The following formatting commands are intended to alter  the
  185.             font  in  which  text  is  displayed,  but  not to alter the
  186.             indentation or justification state of the text:
  187.  
  188.                  Bold -- causes the affected text to be in a bold  font.
  189.                       Nested  bold  commands  have  the same effect as a
  190.                       single bold command.
  191.                  Italic -- causes the affected text to be in  an  italic
  192.                       font.  Nested italic commands have the same effect
  193.                       as a single italic command.
  194.                  Fixed -- causes the affected text  to  be  in  a  fixed
  195.                       width  font.   Nested fixed commands have the same
  196.                       effect as a single fixed command.
  197.                  Smaller -- causes the affected text to be in a  smaller
  198.                       font.   It  is  recommended  that the font size be
  199.                       changed by two points, but other  amounts  may  be
  200.                       more  appropriate  in  some  environments.  Nested
  201.                       smaller commands produce  ever-smaller  fonts,  to
  202.                       the  limits  of  the  implementation's capacity to
  203.                       reasonably  display  them,  after  which   further
  204.                       smaller commands have no incremental effect.
  205.                  Bigger -- causes the affected text to be  in  a  bigger
  206.                       font.   It  is  recommended  that the font size be
  207.                       changed by two points, but other  amounts  may  be
  208.                       more  appropriate  in  some  environments.  Nested
  209.                       bigger commands produce ever-bigger fonts, to  the
  210.                       limits   of   the   implementation's  capacity  to
  211.                       reasonably  display  them,  after  which   further
  212.                       bigger commands have no incremental effect.
  213.                  Underline -- causes the affected text to be underlined.
  214.                       Nested  underline commands have the same effect as
  215.                       a single underline command.
  216.  
  217.             While the "bigger" and "smaller" operators  are  effectively
  218.             inverses,   it   is   not  recommended,  for  example,  that
  219.             "<smaller>" be used  to end the effect of "<bigger>".   This
  220.             is properly done with "</bigger>".
  221.  
  222.             Justification Commands
  223.  
  224.  
  225.  
  226.  
  227.             Borenstein - text/eExpires September 1, 1993          Page 4
  228.  
  229.  
  230.  
  231.  
  232.             Borenstein     A text/enriched type for MIME  April 1993 [5]
  233.  
  234.  
  235.             Initially, text/enriched text is intended  to  be  displayed
  236.             fully-justified  with appropriate fill, kerning, and letter-
  237.             tracking as suits the capabilities  of  the  receiving  user
  238.             agent software.  Actual line width is left to the discretion
  239.             of  the  receiver,  which  is   expected   to   fold   lines
  240.             intelligently  (preferring  soft line breaks) to the best of
  241.             its ability.
  242.  
  243.             The following commands alter  that  state.   Each  of  these
  244.             commands  force a line break before and after the formatting
  245.             command if  there  is  not  otherwise  a  line  break.   For
  246.             example, if one of these commands occurs anywhere other than
  247.             the beginning of a line of text as presented, a new line  is
  248.             begun.
  249.  
  250.                  Center -- causes the affected text to be centered.
  251.                  FlushLeft -- causes  the  affected  text  to  be  left-
  252.                       justified with a ragged right margin.
  253.                  FlushRight -- causes the affected  text  to  be  right-
  254.                       justified with a ragged left margin.
  255.  
  256.             The center, flushleft, and flushright commands are  mutually
  257.             exclusive,   and,  when  nested,  the  inner  command  takes
  258.             precedence.
  259.  
  260.             Note  that  for  some   non-ASCII   character   sets,   full
  261.             justification  may  be inappropriate. In these cases, a user
  262.             agent may choose not to justify such data.
  263.  
  264.             Indentation Commands
  265.  
  266.             Initially, text/enriched text is displayed using the maximum
  267.             available  margins.   Two formatting commands may be used to
  268.             affect the margins.
  269.  
  270.                  Indent -- causes the running left margin to be moved to
  271.                       the  right.  The recommended indentation change is
  272.                       the width of four characters, but this may  differ
  273.                       among implementations.
  274.                  IndentRight -- causes the running right  margin  to  be
  275.                       moved  to  the  left.  The recommended indentation
  276.                       change is the width of four characters,  but  this
  277.                       may differ among implementations.
  278.  
  279.             A line break is NOT forced by a change  of  the  margin,  to
  280.             permit  the description of "hanging" text.  Thus for example
  281.  
  282.  
  283.  
  284.             Borenstein - text/eExpires September 1, 1993          Page 5
  285.  
  286.  
  287.  
  288.  
  289.             Borenstein     A text/enriched type for MIME  April 1993 [6]
  290.  
  291.  
  292.             the following text:
  293.  
  294.             Now <indent> is the time for all good horses to come to  the
  295.             aid  of  their stable, assuming that </indent> any stable is
  296.             really stable.
  297.  
  298.             would be displayed in a 40-character-wide window as follows:
  299.  
  300.             Now is the time for all good horses to
  301.                 come to the aid of their stable,
  302.                 assuming that any stable is
  303.             really stable.
  304.  
  305.             Miscellaneous Commands
  306.  
  307.                  Excerpt -- causes the affected text to  be  interpreted
  308.                       as a textual excerpt from another source, probably
  309.                       a message being responded to.  Typically this will
  310.                       be  displayed  using  indentation and an alternate
  311.                       font, or by indenting  lines  and  preceding  them
  312.                       with  ">  ",  but  such  decisions  are  up to the
  313.                       implementation.  (Note that this is the only truly
  314.                       declarative markup construct in text/enriched, and
  315.                       as such doesn't  fit  very  well  with  the  other
  316.                       facilities, but it describes a type of markup that
  317.                       is  very  commonly  used  in  email  and  has   no
  318.                       procedural  analogue.)    Note  that  as  with the
  319.                       justification  commands,   the   excerpt   command
  320.                       implicitly  begins  and  ends with a line break if
  321.                       one is not already there.
  322.                  Verbatim -- causes the affected text  to  be  displayed
  323.                       without filling, justification, any interpretation
  324.                       of embedded  formatting  commands,  or  the  usual
  325.                       special  rules  for CRLF handling.  Note, however,
  326.                       that the  end  token  </verbatim>  must  still  be
  327.                       recognized.
  328.                  Nofill -- causes the  affected  text  to  be  displayed
  329.                       without   filling   or  justification,  and  hence
  330.                       without any special handling of  CRLFs,  but  with
  331.                       all remaining text/enriched features continuing to
  332.                       apply.
  333.                  Param -- Marks the affected text as command parameters,
  334.                       to  be interpreted or ignored by the text/enriched
  335.                       interpreter, but NOT to be shown to the reader.
  336.  
  337.  
  338.  
  339.  
  340.  
  341.             Borenstein - text/eExpires September 1, 1993          Page 6
  342.  
  343.  
  344.  
  345.  
  346.             Borenstein     A text/enriched type for MIME  April 1993 [7]
  347.  
  348.  
  349.             Note that while the absence of a quoting mechanism makes  it
  350.             slightly   challenging   to   include   the  literal  string
  351.             "</verbatim>" inside of a verbatim environment,  it  can  be
  352.             done  by  breaking up the verbatim segment into two verbatim
  353.             segments as follows:
  354.  
  355.                  <verbatim>
  356.                  ...slightly challenging to include the literal string
  357.                  "</</verbatim><verbatim>verbatim>" inside of a verbatim
  358.                  environment...
  359.                  </verbatim>
  360.  
  361.             Note that the above example  demonstrates  that  it  is  not
  362.             desirable  for  an  implementation  to  break  lines between
  363.             tokens.  In particular, there should not  be  a  line  break
  364.             inserted between the "</verbatim>" and the "<verbatim>" that
  365.             follows it.
  366.  
  367.             Balancing and Nesting of Formatting Commands
  368.  
  369.             Pairs of formatting commands must be properly  balanced  and
  370.             nested.  Thus, a proper way to describe text in bold italics
  371.             is:
  372.  
  373.                       <bold><italic>the-text</italic></bold>
  374.  
  375.                  or, alternately,
  376.  
  377.                       <italic><bold>the-text</bold></italic>
  378.  
  379.                  but,  in  particular,  the  following  is  illegal
  380.                  text/enriched:
  381.  
  382.                       <bold><italic>the-text</bold></italic>
  383.  
  384.             The nesting requirement for formatting  commands  imposes  a
  385.             slightly  higher  burden upon the composers of text/enriched
  386.             bodies, but potentially simplifies text/enriched  displayers
  387.             by  allowing  them  to  be  stack-based.   The  main goal of
  388.             text/enriched is to be  simple  enough  to  make  multifont,
  389.             formatted  email  widely  readable,  so  that those with the
  390.             capability of  sending  it  will  be  able  to  do  so  with
  391.             confidence.   Thus  slightly  increased  complexity  in  the
  392.             composing software was  deemed  a  reasonable  tradeoff  for
  393.             simplified  reading  software.  Nonetheless, implementors of
  394.             text/enriched readers are encouraged to follow  the  general
  395.  
  396.  
  397.  
  398.             Borenstein - text/eExpires September 1, 1993          Page 7
  399.  
  400.  
  401.  
  402.  
  403.             Borenstein     A text/enriched type for MIME  April 1993 [8]
  404.  
  405.  
  406.             Internet  guidelines  of being conservative in what you send
  407.             and liberal in what you accept.  Those implementations  that
  408.             can  do so are encouraged to deal reasonably with improperly
  409.             nested text/enriched data.
  410.  
  411.             Unrecognized formatting commands
  412.  
  413.             Implementations  must  regard  any  unrecognized  formatting
  414.             command  as "no-op" commands, that is, as commands having no
  415.             effect,   thus    facilitating    future    extensions    to
  416.             "text/enriched".  Private  extensions  may  be defined using
  417.             formatting commands that begin  with  "X-",  by  analogy  to
  418.             Internet mail header field names.
  419.  
  420.             In  order  to  formally  define  extended  commands,  a  new
  421.             Internet document should be published.
  422.  
  423.             "White Space" in Text/enriched Data
  424.  
  425.  
  426.             No special behavior is required for the SPACE  or  TAB  (HT)
  427.             character.   It is recommended, however, that, at least when
  428.             fixed-width fonts are in use, the common  semantics  of  the
  429.             TAB  (HT) character should be observed, namely that it moves
  430.             to the next column position that is a multiple  of  8.   (In
  431.             other  words,  if  a  TAB (HT) occurs in column n, where the
  432.             leftmost column is column 0, then that TAB  (HT)  should  be
  433.             replaced  by  8-(n mod 8) SPACE characters.)  It should also
  434.             be noted that some mail gateways are  notorious  for  losing
  435.             (or, less commonly, adding) white space at the end of lines,
  436.             so reliance on SPACE or TAB characters at the end of a  line
  437.             is not recommended.
  438.  
  439.             Initial State of a text/enriched interpreter
  440.  
  441.  
  442.             Text/enriched  is  assumed  to  begin  with  filled,   fully
  443.             justified text in a variable-width font in a normal typeface
  444.             and a size that is average for the current display and user.
  445.             The  left  and right margins are assumed to be maximal, that
  446.             is, at the leftmost and rightmost acceptable positions.
  447.  
  448.             Non-ASCII character sets
  449.  
  450.  
  451.             If the character set specified by the charset  parameter  on
  452.  
  453.  
  454.  
  455.             Borenstein - text/eExpires September 1, 1993          Page 8
  456.  
  457.  
  458.  
  459.  
  460.             Borenstein     A text/enriched type for MIME  April 1993 [9]
  461.  
  462.  
  463.             the  Content-type  line  is  anything other than "US-ASCII",
  464.             this means that the text being  described  by  text/enriched
  465.             formatting   commands  is  in  a  non-ASCII  character  set.
  466.             However, the commands themselves are still  the  same  ASCII
  467.             commands that are defined in this document.  This creates an
  468.             ambiguity only with reference  to  the  "<"  character,  the
  469.             octet with numeric value 60.  In single byte character sets,
  470.             such as the ISO-8859 family, this  is  not  a  problem;  the
  471.             octet  60  can  be quoted by including it twice, just as for
  472.             ASCII.  The problem is more  complicated,  however,  in  the
  473.             case  of multi-byte character sets, where the octet 60 might
  474.             appear at any point in the byte sequence for any of  several
  475.             characters.
  476.  
  477.             In practice, however, most multibyte character sets  address
  478.             this problem internally. For example, the ISO-2022 family of
  479.             character sets can switch back into  ASCII  at  any  moment.
  480.             Therefore   it   is  specified  that,  before  text/enriched
  481.             formatting commands, the prevailing character set should  be
  482.             "switched  back"  into ASCII, and that only those characters
  483.             which would be interpreted as "<" in plain  text  should  be
  484.             interpreted as token delimiters in text/enriched.
  485.  
  486.             The question of what to do for hypothetical future character
  487.             sets  that  do  NOT  subsume  ASCII is not addressed in this
  488.             memo.
  489.  
  490.             Minimal text/enriched conformance
  491.  
  492.  
  493.             A minimal text/enriched implementation is  one  that  simply
  494.             recognizes   the   beginning   and   ending   of  "verbatim"
  495.             environments and, outside of them,  converts  "<<"  to  "<",
  496.             removes  everything  between  a <param> command and the next
  497.             balancing </param> command,  removes  all  other  formatting
  498.             commands (all text enclosed in angle brackets), converts any
  499.             series of n CRLFs to n-1 CRLFs, and converts any  lone  CRLF
  500.             pairs to SPACE.
  501.  
  502.             Notes for Implementors
  503.  
  504.  
  505.             It is recognized that implementors of  future  mail  systems
  506.             will  want rich text functionality far beyond that currently
  507.             defined for text/enriched.  The intent of  text/enriched  is
  508.             to provide a common format for expressing that functionality
  509.  
  510.  
  511.  
  512.             Borenstein - text/eExpires September 1, 1993          Page 9
  513.  
  514.  
  515.  
  516.  
  517.             Borenstein     A text/enriched type for MIME April 1993 [10]
  518.  
  519.  
  520.             in a form in which much of it, at least, will be  understood
  521.             by  interoperating  software.  Thus, in particular, software
  522.             with a richer notion of formatted  text  than  text/enriched
  523.             can still use text/enriched as its basic representation, but
  524.             can extend it with new formatting  commands  and  by  hiding
  525.             information    specific   to   that   software   system   in
  526.             text/enriched <param> constructs. As such systems evolve, it
  527.             is  expected  that  the  definition of text/enriched will be
  528.             further refined  by  future  published  specifications,  but
  529.             text/enriched  as  defined here provides a platform on which
  530.             evolutionary refinements can be based.
  531.  
  532.             An expected common way that sophisticated mail programs will
  533.             generate    text/enriched    data    is   as   part   of   a
  534.             multipart/alternative construct.  For example, a mail  agent
  535.             that  can  generate enriched mail in ODA format can generate
  536.             that mail in a more widely interoperable form by  generating
  537.             both text/enriched and ODA versions of the same data, e.g.:
  538.  
  539.                  Content-type: multipart/alternative; boundary=foo
  540.  
  541.                  --foo
  542.                  Content-type: text/enriched
  543.  
  544.                  [text/enriched version of data]
  545.                  --foo
  546.                  Content-type: application/oda
  547.  
  548.                  [ODA version of data]
  549.                  --foo--
  550.  
  551.             If such a message  is  read  using  a  MIME-conformant  mail
  552.             reader  that  understands  ODA,  the  ODA  version  will  be
  553.             displayed; otherwise,  the  text/enriched  version  will  be
  554.             shown.
  555.  
  556.             In some environments, it  might  be  impossible  to  combine
  557.             certain text/enriched formatting commands, whereas in others
  558.             they might be combined easily.  For example, the combination
  559.             of <bold> and <italic> might produce bold italics on systems
  560.             that support such fonts, but there exist  systems  that  can
  561.             make  text bold or italicized, but not both.  In such cases,
  562.             the most recently issued (innermost)  recognized  formatting
  563.             command should be preferred.
  564.  
  565.  
  566.  
  567.  
  568.  
  569.             Borenstein - text/eExpires September 1, 1993         Page 10
  570.  
  571.  
  572.  
  573.  
  574.             Borenstein     A text/enriched type for MIME April 1993 [11]
  575.  
  576.  
  577.             One of the major goals in the design of text/enriched was to
  578.             make it so simple that even text-only mailers will implement
  579.             enriched-to-plain-text  translators,  thus  increasing   the
  580.             likelihood that enriched text will become "safe" to use very
  581.             widely.  To demonstrate this simplicity, an extremely simple
  582.             C  program that converts text/enriched input into plain text
  583.             output is included in Appendix A.
  584.  
  585.             Extensions to text/enriched
  586.  
  587.  
  588.             It is expected that various mail system authors will  desire
  589.             extensions   to   text/enriched.   The   simple   syntax  of
  590.             text/enriched,  and  the  specification  that   unrecognized
  591.             formatting  commands should simply be ignored, are intend to
  592.             promote such extensions.
  593.  
  594.             Beyond simply defining new formatting commands, however,  it
  595.             may  sometimes  be  necessary  to define formatting commands
  596.             that can take arguments.  This is the intended  use  of  the
  597.             <param>  construct.   In particular, software that wished to
  598.             extend text/enriched to include colored text might define an
  599.             "x-color"  environment  which always began with a color name
  600.             parameter, to indicate the desired color  for  the  affected
  601.             text.
  602.             An Example
  603.  
  604.             Putting all this  together,  the  following  "text/enriched"
  605.             body fragment:
  606.  
  607.                       From: Nathaniel Borenstein <nsb@bellcore.com>
  608.                       To: Ned Freed <ned@innosoft.com>
  609.                       Content-type: text/enriched
  610.  
  611.                       <bold>Now</bold> is the time for
  612.                       <italic>all</italic> good men
  613.                        <smaller>(and <<women>)</smaller> to
  614.                       <ignoreme>come</ignoreme>
  615.  
  616.                       to the aid of their
  617.  
  618.  
  619.                       <x-color><param>red</param>beloved</x-color>
  620.                       country.
  621.  
  622.  
  623.  
  624.  
  625.  
  626.             Borenstein - text/eExpires September 1, 1993         Page 11
  627.  
  628.  
  629.  
  630.  
  631.             Borenstein     A text/enriched type for MIME April 1993 [12]
  632.  
  633.  
  634.                       <verbatim>
  635.                       By the way, I think that <smaller>
  636.                       should
  637.                       REALLY be called
  638.                       <tinier>
  639.                       and that I am always right.
  640.                       -- the end
  641.                       </verbatim>
  642.  
  643.             represents the following  formatted  text  (which  will,  no
  644.             doubt,  look  somewhat  cryptic  in the text-only version of
  645.             this document):
  646.  
  647.                  Now is the time for all good men (and <women>)  to
  648.                  come
  649.                  to the aid of their
  650.  
  651.                  beloved country.
  652.                  By the way, I think that <smaller>
  653.                  should
  654.                  REALLY be called
  655.                  <tinier>
  656.                  and that I am always right.
  657.                  -- the end
  658.  
  659.             where the word "beloved" would be in red on a color  display
  660.             if   the   receiving   software  implemented  the  "x-color"
  661.             extension.
  662.  
  663.           Security Considerations
  664.  
  665.             Security issues are not  discussed  in  this  memo,  as  the
  666.             mechanism raises no security issues.
  667.  
  668.           Author's Address
  669.  
  670.             For more information, the author of  this  document  may  be
  671.             contacted via Internet mail:
  672.  
  673.                                 Nathaniel S. Borenstein
  674.                                  MRE 2D-296, Bellcore
  675.                                      445 South St.
  676.                                Morristown, NJ 07962-1910
  677.  
  678.                                 Phone: +1 201 829 4270
  679.  
  680.  
  681.  
  682.  
  683.             Borenstein - text/eExpires September 1, 1993         Page 12
  684.  
  685.  
  686.  
  687.  
  688.             Borenstein     A text/enriched type for MIME April 1993 [13]
  689.  
  690.  
  691.                                  Fax:  +1 201 829 5963
  692.                                 Email: nsb@bellcore.com
  693.  
  694.             Acknowledgements
  695.  
  696.  
  697.             This document  reflects  the  input  of  many  contributors,
  698.             readers,    and    implementors   of   the   original   MIME
  699.             specification, RFC 1341.  The current  draft  also  reflects
  700.             particular contributions and comments from Terry Crowley and
  701.             Rhys Weatherley.
  702.  
  703.           References
  704.  
  705.             [RFC-1341]   Borenstein,   N.,   and   N.   Freed,     "MIME
  706.             (Multipurpose  Internet  Mail  Extensions):  Mechanisms  for
  707.             Specifying and Describing the  Format  of  Internet  Message
  708.             Bodies", RFC 1341, June, 1992.
  709.  
  710.             [RFC-MIME]   Borenstein,   N.,   and   N.   Freed,     "MIME
  711.             (Multipurpose    Internet   Mail   Extensions)   Part   One:
  712.             Mechanisms for  Specifying  and  Describing  the  Format  of
  713.             Internet Message Bodies", RFC ********, *****, 1993.
  714.  
  715.             Appendix A -- A Simple enriched-to-plain Translator in C
  716.  
  717.  
  718.             One of the major goals in the design  of  the  text/enriched
  719.             subtype  of  the text Content-Type is to make formatted text
  720.             so  simple  that  even  text-only  mailers  will   implement
  721.             enriched-to-plain-text   translators,  thus  increasing  the
  722.             likelihood that multifont text will  become  "safe"  to  use
  723.             very  widely.   To demonstrate this simplicity, what follows
  724.             is a simple C program that converts text/enriched input into
  725.             plain  text  output.  Note that the local newline convention
  726.             (the single character represented by  "\n")  is  assumed  by
  727.             this  program,  but  that  special  CRLF  handling  might be
  728.             necessary on some systems..
  729.  
  730.                  #include <stdio.h>
  731.                  #include <ctype.h>
  732.  
  733.                  main() {
  734.                      int c, i, paramct=0, newlinect=0, verbatim=0,
  735.                  nofill=0;
  736.  
  737.  
  738.  
  739.  
  740.             Borenstein - text/eExpires September 1, 1993         Page 13
  741.  
  742.  
  743.  
  744.  
  745.             Borenstein     A text/enriched type for MIME April 1993 [14]
  746.  
  747.  
  748.                      char token[62], *p;
  749.  
  750.                      while ((c=getc(stdin)) != EOF) {
  751.                          if (c == '<') {
  752.                              if (verbatim != 0) {
  753.                                  for (i=0, p=token; (*p++ = getc(stdin))
  754.                  != EOF
  755.                                      && !lc2strncmp(token, "/verbatim>",
  756.                  i+1) && i<9; i++) {}
  757.                                  if (i==9) {
  758.                                      verbatim = 0;
  759.                                  } else {
  760.                                      *p = '\0';
  761.                                      putc('<', stdout);
  762.                                      fputs(token, stdout);
  763.                                  }
  764.                                  continue;
  765.                              } else {
  766.                                  newlinect=0;
  767.                                  c = getc(stdin);
  768.                                  if (c == '<') {
  769.                                      if (paramct <= 0) putc(c, stdout);
  770.                                  } else {
  771.                                      ungetc(c, stdin);
  772.                                      for (i=0, p=token; (c=getc(stdin))
  773.                  != EOF && c != '>'; i++) {
  774.                                          if (i < sizeof(token)-1) *p++ =
  775.                  isupper(c) ? tolower(c) : c;
  776.                                      }
  777.                                      *p = '\0';
  778.                                      if (c == EOF) break;
  779.                                      if (strcmp(token, "param") == 0)
  780.                                          paramct++;
  781.                                      else if (strcmp(token, "verbatim")
  782.                  == 0)
  783.                                          verbatim = 1;
  784.                                      else if (strcmp(token, "nofill") ==
  785.                  0)
  786.                                          nofill++;
  787.                                      else if (strcmp(token, "/param") ==
  788.                  0)
  789.                                          paramct--;
  790.                                      else if (strcmp(token, "/nofill")
  791.                  == 0)
  792.  
  793.  
  794.  
  795.  
  796.  
  797.             Borenstein - text/eExpires September 1, 1993         Page 14
  798.  
  799.  
  800.  
  801.  
  802.             Borenstein     A text/enriched type for MIME April 1993 [15]
  803.  
  804.  
  805.                                          nofill--;
  806.                                  }
  807.                              }
  808.                       } else {
  809.                          if (paramct > 0)
  810.                            ; /* ignore params */
  811.                             else if (c == '\n' && verbatim == 0 &&
  812.                  nofill <= 0)
  813.                                 if (++newlinect > 1) {
  814.                                     putc(c, stdout);
  815.                                 } else {
  816.                                     putc(' ', stdout);
  817.                                 }
  818.                             else {
  819.                                 newlinect = 0;
  820.                                 putc(c, stdout);
  821.                             }
  822.                       }
  823.                      }
  824.                      /* The following line is only needed with line-
  825.                  buffering */
  826.                      putc('\n', stdout);
  827.                      exit(0);
  828.                  }
  829.  
  830.                  lc2strncmp(s1, s2, len)
  831.                  char *s1, *s2;
  832.                  int len;
  833.                  {
  834.                      if (!s1 || !s2) return (-1);
  835.                      while (*s1 && *s2 && len > 0) {
  836.                       if (*s1 != *s2 && (tolower(*s1) != *s2)) return(-
  837.                  1);
  838.                       ++s1; ++s2; --len;
  839.                      }
  840.                      if (len <= 0) return(0);
  841.                      return((*s1 == *s2) ? 0 : -1);
  842.                  }
  843.             It should be noted that one can do considerably better  than
  844.             this  in  displaying  text/enriched data on a dumb terminal.
  845.             In particular, one can  replace  font  information  such  as
  846.             "bold"  with  textual emphasis (like *this* or   _T_H_I_S_).
  847.             One can also properly handle  the  text/enriched  formatting
  848.             commands  regarding  indentation, justification, and others.
  849.             However, the above program is all that is necessary in order
  850.             to  present text/enriched on a dumb terminal without showing
  851.  
  852.  
  853.  
  854.             Borenstein - text/eExpires September 1, 1993         Page 15
  855.  
  856.  
  857.  
  858.  
  859.             Borenstein     A text/enriched type for MIME April 1993 [16]
  860.  
  861.  
  862.             the user any formatting artifacts.
  863.  
  864.             Appendix B -- Differences from RFC 1341  text/richtext
  865.  
  866.             Text/enriched  is  a  clarification,   simplification,   and
  867.             refinement of the type defined as text/richtext in RFC 1341.
  868.             For the benefit of  those  who  are  already  familiar  with
  869.             text/richtext,   or  for  those  who  want  to  exploit  the
  870.             similarities to be able to display text/richtext  data  with
  871.             their  text/enriched  software,  the differences between the
  872.             two are summarized here. Note, however,  that  text/enriched
  873.             is  intended  to  make  text/richtext obsolete, so it is not
  874.             recommended that new software generate text/richtext.
  875.  
  876.             0.  The name "richtext" was changed to "enriched",  both  to
  877.             differentiate   the  two  versions  and  because  "richtext"
  878.             created widespread  confusion  with  Microsoft's  Rich  Text
  879.             Format (RTF).
  880.  
  881.             1.   Clarifications.   Many   things   were   ambiguous   or
  882.             unspecified  in  the  text/richtext definition, particularly
  883.             the  initial  state  and  the  semantics  of  richtext  with
  884.             multibyte  character  sets.   However,  such differences are
  885.             OPERATIONALLY irrelevant, since the  clarifications  offered
  886.             in  this document are at least reasonable interpretations of
  887.             the text/richtext specification.
  888.  
  889.             2.  Newline semantics have changed.  In  text/richtext,  all
  890.             CRLFs  were mapped to spaces, and line breaks were indicated
  891.             by "<nl>".  This has been replaced by  the  "n-1"  rule  for
  892.             CRLFs.
  893.  
  894.             3.  The representation of a literal "<" character was "<lt>"
  895.             in text/richtext, but is "<<" in text/enriched.
  896.  
  897.             4.  The "verbatim" and "nofill" commands did  not  exist  in
  898.             text/richtext.
  899.  
  900.             5.  The "param" command did not exist in text/richtext.
  901.  
  902.             6.  The following  commands  from  text/richtext  have  been
  903.             REMOVED    from    text/enriched:    <COMMENT>,   <OUTDENT>,
  904.             <OUTDENTRIGHT>,  <SAMEPAGE>,   <SUBSCRIPT>,   <SUPERSCRIPT>,
  905.             <HEADING>,    <FOOTING>,    <ISO-8859-[1-9]>,    <US-ASCII>,
  906.             <PARAGRAPH>, <SIGNATURE>, <NO-OP>, <LT>, <NL>, and <NP>.
  907.  
  908.  
  909.  
  910.  
  911.             Borenstein - text/eExpires September 1, 1993         Page 16
  912.  
  913.  
  914.  
  915.  
  916.             Borenstein     A text/enriched type for MIME April 1993 [17]
  917.  
  918.  
  919.             7.  All claims of  SGML  compatibility  have  been  dropped.
  920.             However,  with  the possible exceptions of the new semantics
  921.             for CRLF and "<<" can be implemented,  text/enriched  should
  922.             be no less SGML-friendly than text/richtext was.
  923.  
  924.             8.  In text/richtext, there were three commands (<NL>, <NP>,
  925.             and  <LT>)  that  did  not  use balanced closing delimiters.
  926.             Since all of  these  have  been  eliminated,  there  are  NO
  927.             exceptions to the nesting/balancing rules in text/enriched.
  928.  
  929.             9.  The limit on the size  of  formatting  tokens  has  been
  930.             increased from 40 to 60 characters.
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.             Borenstein - text/eExpires September 1, 1993         Page 17
  969.  
  970.